window.onload=function(){
    var form=document.forms["testform"];
    form.ondrop=function(e){
        previewfile(e.dataTransfer.files[0])
    }
    var holder = document.getElementById('holder');

function previewfile(file) {
  if (typeof FileReader != 'undefined'=== true  ) {
    var reader = new FileReader();
    reader.onload = function (event) {
      var image = new Image();
      image.src = event.target.result;
      image.width = 250; // a fake resize
      while(holder.firstChild){
          holder.removeChild(holder.firstChild);
      }
      holder.appendChild(image);
    };

    reader.readAsDataURL(file);
  } else {
    holder.innerHTML += '<p>Uploaded ' + file.name + ' ' + (file.size ? (file.size/1024|0) + 'K' : '');
    console.log(file);
  }
}
    
}